﻿using Net5ApiANdWpfClient.Lib.Common;
using Net5ApiANdWpfClient.Lib.Model;
using Net5ApiANdWpfClient.Lib.Model.SystemAdmin;
using Net5ApiANdWpfClient.Lib.Service;
using Net5ApiANdWpfClient.WpfClient.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Net5ApiANdWpfClient.WpfClient.SystemManager
{
    /// <summary>
    /// AdminUserManager.xaml 的交互逻辑
    /// </summary>
    public partial class AdminUserManager : BaseUserControl
    {
        public AdminUserManager()
        {
            InitializeComponent();
            adminUserPage.PageSize = PcConfig.PageSize;
            adminUserPage.PageCurrent = 1;
            Search();
        }
        public int Search()
        {
            string loginName = un.Text;
            string fullName = unf.Text;
            PagerResult<AdminUser> result = new AdminUserService().SearchPage(loginName, fullName, adminUserPage.PageCurrent);
            if (result != null)
            {
                userList.DataContext = result.Data;
                adminUserPage.NMax = result.RowCount;
                return result.RowCount;
            }
            return 0;
        }
        private void SearchBtn_Click(object sender, RoutedEventArgs e)
        {
            Search();
        }



        private int AdminUserPage_EventPaging(Common.EventPagingArg e)
        {
             return Search();
        }

        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            MainWindow main = WindowsManager.GetWindowInCurrentWindows<MainWindow>();
            if (main != null)
            {
                WindowsManager.MdiWindowShowChildShow(typeof( AdminUserAdd), main.MainMdiWindow, "添加用户");
            }
          
        }
    }
}
